#include "RaceModel.h"

#include <DndData/DndData.h>
#include <DndData/Race.h>

#include <QTimer>

RaceModel::RaceModel(const Race *source, QObject *parent)
    : TitledDataModel(source, parent)
{
    // category 3
    addCategory("Ability Bonus");
    // category 4
    addCategory("Skill Bonus");
    // category 5
    addCategory("Powers and Traits");

    // adding to description category
    addEntry(2, QString("Height: %1\'%2\" - %3\'%4\"")
             .arg(source->heightMin / 12).arg(source->heightMin % 12)
             .arg(source->heightMax / 12).arg(source->heightMax % 12));
    addEntry(2, QString("Weight: %1 - %2")
             .arg(source->weightMin).arg(source->weightMax));
    addEntry(2, QString("Size: %1").arg(DndData::SIZE_NAMES[source->size]));
    addEntry(2, QString("Speed: %1").arg(source->speed));

    // adding to ability bonus cat 3
    QList<DndData::Ability>::const_iterator it = source->abilityBonus.constBegin();
    for ( ; it != source->abilityBonus.constEnd(); ++it )
    {
        DndData::Ability ab = *it;
        addEntry(3, QString("+2 to %1").arg(DndData::ABILITY_NAMES[ab]));

    // adding to skill bonus cat 4
    QList<DndData::SkillTypes>::const_iterator it = source->skillBonus.constBegin();
    for ( ; it != source->skillBonus.constEnd(); ++it )
    {
        DndData::SkillTypes sk = *it;
        addEntry(4, QString("+2 to %1").arg(DndData::SKILL_TYPES[sk]));
    }
    }

}
